package org.android.SuperList;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.database.Cursor;
import android.graphics.Typeface;
import android.util.Log;
import android.view.Menu;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;

public class clsGeneral extends Activity
{
	public static final int ctrl_Button=0;
	public static final int ctrl_TextView=1;
	public static final int ctrl_EditText=2;
	public static final int ctrl_Spinner=3;
	public static final int ctrl_DatePicker=4;
	public static final int ACTIVITY_CREAR=0;
	public static final int ACTIVITY_EDITAR=1;
	public static final int ACTIVITY_DETALLE=2;
	public static final int ACTIVITY_CATALOGOS=3;
	public static final int MENU_INSERTAR = Menu.FIRST;
	public static final int MENU_ELIMINAR = Menu.FIRST + 1;
	public static final int MENU_EDITAR = Menu.FIRST + 2;
	public static final int MENU_CATALOGOS = Menu.FIRST + 3;
	public static final int MENU_CANCELAR = Menu.FIRST + 4;
	public static final String LBL_ERROR="@string/msg_ops";
	public static final String MSG_ERRORINTEGRIDAD="@strings/msg_error_integridad";
	
	
	public boolean setFont(int Control,String path, int res)
    {		
		Typeface font;
		
		switch(Control)
		{
		case ctrl_Button:
			Button Boton = (Button) findViewById(res);
			font = Typeface.createFromAsset(this.getAssets(), path);         
			Boton.setTypeface(font);
		return true;
		case ctrl_TextView:
			TextView Texto = (TextView) findViewById(res);
			font = Typeface.createFromAsset(this.getAssets(), path);         
			Texto.setTypeface(font);
		return true;
		case ctrl_EditText:
			EditText CajaTexto = (EditText) findViewById(res);
			font = Typeface.createFromAsset(this.getAssets(), path);         
			CajaTexto.setTypeface(font);
		return true;		
		}
	return true;		
    }
	
	public static void showAlerts(String Titulo,String Mensaje,Context Contexto)
	{
		AlertDialog.Builder Alerta = new AlertDialog.Builder(Contexto);
		Alerta.setTitle(Titulo);
		Alerta.setMessage(Mensaje);
		
		OnClickListener DialogListener = new DialogInterface.OnClickListener() 
		{		
			
			public void onClick(DialogInterface dialog, int which) 
			{
				Log.i("Dialog Alert","Evento ejecutado");				
			}
		};
		Alerta.setPositiveButton("OK", DialogListener);
		AlertDialog Dialogo = Alerta.create();
		Dialogo.show();
		
	}
	
	public static  int recuperaPocision(String Columna,Spinner Spn, Cursor Lista)
	{
		int i;
		int Campo= new Integer(Lista.getString(Lista.getColumnIndex(Columna)));  
		
		for(i=0;i<Spn.getCount();i++)
		{
			if(Spn.getItemIdAtPosition(i) == Campo)
				break;						
		}
		return(i);
	}
}
